<template>
  <div>
    <el-table ref="multipleTable" :data="list" stripe border class="mt-1"  :row-class-name="tableRowClassName">
      <el-table-column  prop="treatmentPeriod" width="50" label="疗程"/>
      <el-table-column  prop="treatmentTimes" width="50" label="次数"/>
      <el-table-column prop="planTreatmentTime" label="计划治疗日期" min-width="120" />
      <el-table-column prop="treatmentTypeName.name" label="治疗类型" min-width="120" />
      <el-table-column prop="treatmentUseTime" label="预计耗时(分钟)" min-width="120" />
      <el-table-column prop="state" label="状态" min-width="120"  v-if="type!=='setting'">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.state===1">已做</el-tag>
          <el-tag type="waring" v-if="scope.row.state===0">未做</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="issue" label="是否下发" min-width="120"  v-if="type!=='setting'">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.issue===1">已下发</el-tag>
          <el-tag type="waring" v-if="scope.row.issue===0">未下发</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="备注" min-width="120" v-if="type!=='setting'"/>
      <el-table-column label="操作" v-if="type!=='setting'">
        <template slot-scope="scope">
          <el-button type="text" @click="showDialog('update',scope.row)">修改</el-button>
          <el-button type="text" @click="issuePlan('issue',scope.row)" v-if="scope.row.issue!==1">下发</el-button>

          <el-button type="text" @click="deletePlan('delete',scope.row)">删除</el-button>
          <el-button type="text" @click="showDialog1(scope.row)" v-if="scope.row.providerCollection">治疗记录</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog :title="dialog.title" :visible.sync="dialog.open" width="1000" top="70px" :close-on-clcick-modal="false" class="bodyNopaddingTop">
      <treatmentPlanForm :providerId="providerId" @submitSuccess="submitSuccess" :model="dialog.model"  :type="dialog.type" :typeList="typeList"/>
    </el-dialog>

    <el-dialog :title="dialog1.title" :visible.sync="dialog1.open" width="1200" top="70px" :close-on-clcick-modal="false" class="bodyNopaddingTop">
      <el-form :inline="true" :model="dialog1.formData"  label-width="140px" class="demo-ruleForm">
        <el-form-item label="身份证号" prop="idNo">
          <el-input v-model="dialog1.formData.idNo"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="档案号" prop="providerNo">
           <el-input v-model="dialog1.formData.providerNo"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="耗材批号" prop="hcBatchNo">
           <el-input v-model="dialog1.formData.hcBatchNo"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="盐水批号" prop="tysBatchNo">
           <el-input v-model="dialog1.formData.providerNo"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="抗凝剂批号" prop="knjBatchNo">
           <el-input v-model="dialog1.formData.tysBatchNo"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="设置单层采集量" prop="setSingleLayerNum">
           <el-input v-model="dialog1.formData.setSingleLayerNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="设置总采集量" prop="setTotalNum">
           <el-input v-model="dialog1.formData.setTotalNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="设置采集速度" prop="setCollectingSpeed">
           <el-input v-model="dialog1.formData.setCollectingSpeed"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="设置还输速度" prop="setHsSpeed">
           <el-input v-model="dialog1.formData.setHsSpeed"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="设置袖带压力" prop="setCuffPressure">
           <el-input v-model="dialog1.formData.setCuffPressure"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="循环次数" prop="cycles">
           <el-input v-model="dialog1.formData.cycles"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="皮重" prop="initWeight">
           <el-input v-model="dialog1.formData.setTotalNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="总采血量" prop="totalBloodNum">
           <el-input v-model="dialog1.formData.totalBloodNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="总采浆量" prop="totalPlasmaNum">
           <el-input v-model="dialog1.formData.totalPlasmaNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="盐水用量" prop="useYsNum">
           <el-input v-model="dialog1.formData.useYsNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="抗凝剂用量" prop="useKngNum">
           <el-input v-model="dialog1.formData.useKngNum"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="开始安装耗材时间" prop="installStartTime">
           <el-input v-model="dialog1.formData.installStartTime"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="安装耗材完成时间" prop="installEndTime">
           <el-input v-model="dialog1.formData.installEndTime"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="安装耗时" prop="installTaken">
           <el-input v-model="dialog1.formData.installTaken"  class="width220" disabled></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
// 治疗计划form表单
import {selectProviderCollection,deletePlanTreatmentById ,issuePlan} from "plugins/axios/inquiryRecord.js"
import treatmentPlanForm from 'views/operationManage/components/inquiryRecordDetail/treatmentPlan/treatmentPlanForm.vue';
export default {
  components:{
    treatmentPlanForm
  },
  props:{
    providerId:{
       type:[String,Number]
    },
    pid:{
       type:[String,Number]
    },
    list:{
      type:[Array]
    },
    type:{
      type:String
    },
    typeList:{
      type:Array,
      default(){
        return []
      }
    },
  },
  data(){
    return {
      dialog:{
        title:'',
        open:false,
        model:{},
        type:'',
      },
      dialog1:{
        title:'',
        open:false,
        formData:{}
      }
    }
  },
  created(){},
  mounted(){},
  watch:{},
  computed:{},
  methods:{
    issuePlan(type,row){
         let self=this;
       self.$confirm('是否下发?', '提示', {
            confirmButtonText: '下发',
            cancelButtonText: '取消',
            confirmButtonClass:'bg-warning noBorder',
            type: 'warning'
          }).then(() => {
              issuePlan( self.pid,row.id).then(res=>{
                    self.$message.success('下发成功!');
                    self.$emit('successSubmit')
               })
             
            }).catch(()=> {});
    },
    deletePlan(type,row){
      let self=this;
       self.$confirm('是否删除?', '提示', {
            confirmButtonText: '删除',
            cancelButtonText: '取消',
            confirmButtonClass:'bg-warning noBorder',
            type: 'warning'
          }).then(() => {
              deletePlanTreatmentById(row.id).then(res=>{
                    self.$message.success('删除成功!');
                    self.$emit('successSubmit')
               })
             
            }).catch(()=> {});
    },
    showDialog(type,row){


      this.dialog.open = true;
      this.dialog.type=type;
      this.dialog.title=`${type==='insert'?'新增':'修改'}治疗计划`
      this.dialog.model = type==='insert'?{}:{...row}



    },
    submitSuccess(){
       this.dialog.open = false;
       this.$emit('successSubmit')
    },
    showDialog1(row){
      this.dialog1.open = true;
      this.dialog1.title=`治疗记录`
      selectProviderCollection(row.providerCollection).then(res=>{
        this.dialog1.formData=res.content;
      })
    },
    tableRowClassName({row, rowIndex}){
      let date=this.timestampToTime(new Date(),'yyyy-mm-dd') ;
      console.log(date);
      if(row.planTreatmentDate===date){
        return 'info-row'
      }
    }
  }
}
</script>
<style scoped>
</style>